from bson import ObjectId
from pydantic import BaseModel, Field
from typing import Optional, List
from datetime import datetime

class Article(BaseModel):
    id: str = Field(default_factory=lambda: str(ObjectId()), alias="_id")
    e_id: int
    author: str
    platform: str
    content: str
    like: int
    comments: int
    share: int
    link: str
    time: str
    sentiment: str
    intensity: float

class Comment(BaseModel):
    id: str = Field(default_factory=lambda: str(ObjectId()), alias="_id")
    e_id: int
    user: str
    content: str
    like: int
    time: str
    sentiment: str
    intensity: float

class Event(BaseModel):
    id: str = Field(default_factory=lambda: str(ObjectId()), alias="_id")
    id: int  # Note: This is different from _id
    title: str
    date: datetime
    type: Optional[str] = None
    platform: str
    sentiment: Optional[str] = None
    comments: int
    region: Optional[str] = None
    articles: int
    keywords: List[str]
    description: str

class User(BaseModel):
    id: str = Field(default_factory=lambda: str(ObjectId()), alias="_id") # 自动生成id
    # id: Optional[str] = Field(None, alias="_id")
    username: str
    password: str
    role: int = 0
    created_time: Optional[str]

# class GenerationPrompt(BaseModel):
#     id: str = Field(default_factory=lambda: str(ObjectId()), alias="_id")
#     # id: Optional[str] = Field(None, alias="_id")
#     event_id: str
#     prompt_text: str
#     created_by: str
#     created_time: Optional[str]

class GeneratedComment(BaseModel):
    id: str = Field(default_factory=lambda: str(ObjectId()), alias="_id")
    # id: Optional[str] = Field(None, alias="_id")
    event_id: int
    prompt: str
    content: str
    model_type: Optional[str]
    # is_deleted: int = 0
    last_editor: Optional[str]
    created_time: Optional[str]
    updated_time: Optional[str]


